using System;
using UnityEngine;
using UnityEngine.UIElements;

public class GameWinPanel : MonoBehaviour
{
    private VisualElement rootElement;
    private Button pickCardButton;
    private Button backMapButton;
    
    [Header("广播事件")]
    public ObjectEventSO loadMapEvent;
    public ObjectEventSO piakCardEvent;
    private void OnEnable()
    {
        rootElement = GetComponent<UIDocument>().rootVisualElement;
        pickCardButton = rootElement.Q<Button>("PickCardButton");
        backMapButton = rootElement.Q<Button>("BackMapButton");
        
        backMapButton.clicked += OnBackMapButtonClicked;
        pickCardButton.clicked += OnPickCardButtonClicked;
    }
    

    private void OnPickCardButtonClicked()
    {
        piakCardEvent.RaisEvent(null,this);
    }

    private void OnBackMapButtonClicked()
    {
        loadMapEvent.RaisEvent(null, this);
    }

    public void OnFinishPickCardEvent()
    {
        pickCardButton.style.display = DisplayStyle.None;
    }
    
}
